package com.zbkj.admin.controller;

import com.zbkj.admin.service.AdminOrderHandleService;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.order.AdminOrderQueryRequest;
import com.zbkj.common.request.order.AdminOrderSaveRequest;
import com.zbkj.common.request.order.OrderApprovalRequest;
import com.zbkj.common.response.CommonResult;
import com.zbkj.common.response.UploadResponse;
import com.zbkj.common.response.order.AdminOrderResponse;
import com.zbkj.common.response.order.OrderSucceResponse;
import com.zbkj.common.response.order.UserRechargeResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Auther:
 * @Date: 2024/9/16 01:04
 * @Description:
 */
@RestController
@RequestMapping("api/admin/order")
@Api(tags = "服务端-订单管理服务")
public class AdminOrderController {

    @Autowired
    private AdminOrderHandleService adminOrderHandleService;

    @ApiOperation(value = "充值页获取用户流量包信息")
    @GetMapping(value = "/getUserRechargeInfo/{phone}")
    public CommonResult<UserRechargeResponse> getUserRechargeInfo(@PathVariable("phone") String phone) {
        return CommonResult.success(adminOrderHandleService.getUserRechargeInfo(phone));
    }

    @ApiOperation(value = "订单列表")
    @PostMapping(value = "/list")
    public CommonResult<CommonPage<AdminOrderResponse>> list(@RequestBody AdminOrderQueryRequest paramRequest) {
        return CommonResult.success(CommonPage.restPage(adminOrderHandleService.list(paramRequest)));
    }

    @ApiOperation(value="支付凭证上传")
    @PostMapping("/payVoucheUpload")
    public CommonResult<UploadResponse> payVoucheUpload(MultipartFile file) {
        return CommonResult.success(adminOrderHandleService.payVoucheUpload(file));
    }

    @ApiOperation(value = "订单提交")
    @PostMapping(value = "/orderSave")
    public CommonResult<OrderSucceResponse> orderSave(@RequestBody @Validated AdminOrderSaveRequest saveRequest) {
        return CommonResult.success(adminOrderHandleService.orderSave(saveRequest));
    }

    @ApiOperation(value = "订单审批")
    @PostMapping(value = "/orderApproval")
    public CommonResult orderApproval(@RequestBody @Validated OrderApprovalRequest approvalRequest) {
        adminOrderHandleService.orderApproval(approvalRequest);
        return CommonResult.success();
    }
}
